#ifndef STRATUM_UTILS_H
#define STRATUM_UTILS_H
#include <pthread.h>

struct CommonListItem {
    void* data;
    CommonListItem* next;
    CommonListItem* prev;
};
typedef CommonListItem* PCLI;

typedef void (*LISTFREEPARAM)(void*);

class CommonList {
public:
    CommonList();
    ~CommonList();

    PCLI addHead(void* data);
    PCLI addTail(void* data);

    void enter();
    void leave();
    void del(PCLI item);
    void del(void* data);
    void delAll(LISTFREEPARAM freeParam);
    PCLI find(void* data);
    void swap(PCLI i1, PCLI i2);

    pthread_mutex_t m_mutex;
    int m_count;
    PCLI m_first;
    PCLI m_last;
};


#endif //STRATUM_UTILS_H
